package net.starwifi.duobao.plugin.wo3.tool;

import cn.com.hongpay.client.vo.refund.RefundResVo;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;

/**
 * Created by Administrator on 2015/7/22.
 */
public class PaymentHelper {


    public static RefundResVo getRefundResVo(String response){
        RefundResVo refundResVo=new RefundResVo();
        try {
            response = response.replaceAll("\n", "");
            response = response.replaceAll("\t", "");
            Document doc= DocumentHelper.parseText(response);
            //合作伙伴ID
            org.dom4j.Element elementPartnerID = (org.dom4j.Element) doc.selectSingleNode("/AIPAYTRADE/INFO/PARTNER_ID");
            refundResVo.setPartnerId(elementPartnerID.getStringValue());

            //签名
            org.dom4j.Element elementSign = (org.dom4j.Element) doc.selectSingleNode("/AIPAYTRADE/INFO/SIGNED_MSG");
            refundResVo.setSignedMsg(elementSign.getStringValue());

            //我方订单号
            org.dom4j.Element elementPartnerTradeNo = (org.dom4j.Element) doc.selectSingleNode("/AIPAYTRADE/BODY/PARTNER_TRADE_NO");
            refundResVo.setPartnerTradeNo(elementPartnerTradeNo.getStringValue());

            //支付状态
            org.dom4j.Element elementResultCode = (org.dom4j.Element) doc.selectSingleNode("/AIPAYTRADE/BODY/REFUND_CODE");
            refundResVo.setRefundCode(elementResultCode.getStringValue());

            //支付状态
            org.dom4j.Element elementRefundMsg = (org.dom4j.Element) doc.selectSingleNode("/AIPAYTRADE/BODY/REFUND_MSG");
            refundResVo.setRefundMsg(elementRefundMsg.getStringValue());

            org.dom4j.Element elementRefundRemark = (org.dom4j.Element) doc.selectSingleNode("/AIPAYTRADE/BODY/REFUND_REMARK");
            refundResVo.setRefundRemark(elementRefundRemark.getStringValue());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return refundResVo;
    }


}
